package com.atguigu.gmall.cart.service.impl;

import com.atguigu.gmall.cart.mapper.CartInfoMapper;
import com.atguigu.gmall.cart.service.CartInfoAsyncService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * 购物车开启异步 线程注解实现类
 */
@Service
public class CartInfoAsyncServiceImpl implements CartInfoAsyncService {


    @Autowired
    private CartInfoMapper cartInfoMapper;
    //删除
    @Async
    @Override
    public void deleteDB(Long skuId, String userId) {
        System.out.println("deleteDB：" + Thread.currentThread().getName());
        Map<String, Object> columnMap = new HashMap<>();
        columnMap.put("sku_id",skuId);
        columnMap.put("user_id",userId);
        cartInfoMapper.deleteByMap(columnMap);
    }
}
